# 1.导包
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# 2.创建浏览器驱动对象
# Firefox浏览器:
# driver = webdriver.Firefox()
# Chrome浏览器:
path = r"D:\Programs\Python\Python313\chromedriver.exe"
ser = Service(executable_path = path)
driver = webdriver.Chrome(service = ser)
# 使用Edge浏览器,不需要安装驱动
# driver = webdriver.Edge ()
# 3.打开Web页面
driver.get(f"http://121.43.169.97:8848/pageA.html")
time.sleep(3)
# 大小
result_01 = driver.find_element(by = By.CSS_SELECTOR, value = "#userA").size
print(result_01)
# 文本
result_02 = driver.find_element(by = By.CSS_SELECTOR, value = "a").text
print(result_02)
# 显示链接
result_03 = driver.find_element(by = By.CSS_SELECTOR, value = "a").get_attribute("href")
print(result_03)
# 是否可见--false
result_04 = driver.find_element(by = By.CSS_SELECTOR, value = "span").is_displayed()
print(result_04)
# 是否可用--false
result_05 = driver.find_element(by = By.CSS_SELECTOR, value = "#cancelA").is_enabled()
print(result_05)
# 是否选中--true
result_06 = driver.find_element(by = By.CSS_SELECTOR, value = "#lyA").is_selected()
print(result_06)

# 4.暂停
time.sleep(3)
# 5.关闭浏览器驱动对象
driver.quit()